interface Strategy {
    doOperation(num1: number, num2: number): number;
}

// 2. 实现策略接口
class OperationAdd implements Strategy {
    doOperation(num1: number, num2: number): number {
        return num1 + num2;
    }
}

class OperationSubstract implements Strategy {
    doOperation(num1: number, num2: number): number {
        return num1 - num2;
    }
}

class OperationMultiply implements Strategy {
    doOperation(num1: number, num2: number): number {
        return num1 * num2;
    }
}

// 3. 创建context
class Context {
    private strategy: Strategy;

    constructor(strategy: Strategy) {
        this.strategy = strategy;
    }

    executeStrategy(num1: number, num2: number): number {
        return this.strategy.doOperation(num1, num2);
    }
}

const context = new Context(new OperationAdd());
console.log('10 + 5 = ', context.executeStrategy(10, 5));

context.strategy = new OperationSubstract();
console.log('10 - 5 = ', context.executeStrategy(10, 5));

context.strategy = new OperationMultiply();
console.log('10 * 5 = ', context.executeStrategy(10, 5));